/*
 * @Author: your name
 * @Date: 2021-10-04 11:38:36
 * @LastEditTime: 2021-10-04 13:16:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \diff\src\mysnabbdom\h.js
 */
import vnode from './vnode'
export function h(sel,data,c){

    if(arguments.length!=3){
         throw console.error('参数不正确！！！');  
    }else if(typeof c=='string' || typeof c=='number'){
        //   正在调用h函数
          return vnode(sel,data,[],c,3)
    }else if(Array.isArray(c)){
        //   调用心态2 h(div,{},[] )
        let children = []
        for(let i = 0;i<c.length;i++){
            if(!typeof c[i] == 'object' && c[i].hasOwnProperty('sel')){
                throw error('数组有误！！！')
            }
            children.push(c[i])
        }
           return  vnode(sel,data,children,2,3)
    }else if(typeof c == 'object' && c.hasOwnProperty('sel')){
        //   形态3 h(div,{},h(...))
        return  vnode(sel,data,[c],2,3)
    }
    
}